﻿#include <QProcessEnvironment>
#include <QLibrary>
#include <QFileInfo>
#include <QDir>
#include <qt_windows.h>

QString AppDir()
{
    TCHAR name[MAX_PATH]; GetModuleFileName(GetModuleHandle(NULL), name, MAX_PATH); return QFileInfo(QString::fromWCharArray(name)).dir().path();
}

int main(int argc, char *argv[])
{
    QString appDir = AppDir();

    if (qputenv("PATH", (QProcessEnvironment::systemEnvironment().value("PATH") + ";" + appDir + "/" + "runtimes/native").toLocal8Bit()))
    {
        return reinterpret_cast<int(*)(int, char*[])>(QLibrary::resolve(appDir + "/OiFlangeX.dll", "Entry"))(argc, argv);
    }
    else
    {
        return -1;
    }
}
